package cn.stylefeng.guns.constant;

import cn.stylefeng.roses.core.util.ToolUtil;

import java.math.BigDecimal;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


/**
 * @Description: ConstantsHolderContext
 * @Author liuqiang
 * @Date 2020-02-14 21:20
 */
public class ConstantsHolderContext {
    /**
     * 所有的常量，可以增删改查
     */
    private static Map<String, Object> CONSTNTS_HOLDER = new ConcurrentHashMap<>();

    /**
     * 添加系统常量
     */
    public static void putConstant(String key, Object value) {
        if (ToolUtil.isOneEmpty(key, value)) {
            return;
        }
        CONSTNTS_HOLDER.put(key, value);
    }

    /**
     * 删除常量
     */
    public static void deleteConstant(String key) {
        if (ToolUtil.isOneEmpty(key)) {
            return;
        }

        CONSTNTS_HOLDER.remove(key);
    }

    /**
     * 获取系统常量
     */
    public static Map<String, Object> getConstntsMap() {
        return CONSTNTS_HOLDER;
    }

    public static BigDecimal getRechargeRemind(){
        String remind = (String) CONSTNTS_HOLDER.get("remind_recharge");
        return new BigDecimal(remind);
    }
}
